//
//  YMJTableViewCell.m
//  010-tableView自定义cell
//
//  Created by dllo on 16/7/27.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "YMJTableViewCell.h"


@interface YMJTableViewCell()
@property (nonatomic, strong) UIImageView *mImageView;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@end
@implementation YMJTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        NSLog(@"%@",NSStringFromCGRect(self.frame));
//    默认高度44
        // 在初始化时,320 414 ,不能自定义布局
        
        // 初始化方法中,只负责创建
        _mImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_mImageView];
        _mImageView.backgroundColor = [UIColor blueColor];
        _label = [[UILabel alloc] init];
        [self.contentView addSubview:_label];
        _label.backgroundColor = [UIColor purpleColor];
        _label1 = [[UILabel alloc] init];
        [self.contentView addSubview:_label1];
        _label1.backgroundColor = [UIColor orangeColor];
        _label2 = [[UILabel alloc] init];
        [self.contentView addSubview:_label2];
        _label2.backgroundColor = [UIColor magentaColor];
        // 不要在label 上添加视图 (没有渲染效果)
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
//    NSLog(@"%@,%s",NSStringFromCGRect(self.frame),__FUNCTION__);
    // 负责给视图布局
    _mImageView.frame = CGRectMake(15, 14, 126, self.contentView.frame.size.height);
    _label.frame = CGRectMake(157, 14, 249, 31);
    _label1.frame = CGRectMake(157, 58, 249, 72);
    _label2.frame = CGRectMake(324, 83, 67, 21);

}
// 传个dataModle对象重写setter方法,传值.并且将.h 展现给外面的控件剪切到.m里面
- (void)setDataModel:(DataModel *)dataModel {
    _dataModel = dataModel;
    _mImageView.image = [UIImage imageNamed:dataModel.imageNameStr];
    _label.text = dataModel.titleStr;
    _label1.text = dataModel.titleStr1;
    _label2.text = dataModel.titleStr2;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
